//
//  DGGMobileLoginSDK.m
//  DGGMobileLoginSDK
//
//  Created by dgg_hzk on 2019/11/12.
//  Copyright © 2019 dgg_hzk. All rights reserved.
//

#import "DGGMobileLoginSDK.h"


@interface DGGMobileLoginSDK ()


@end

@implementation DGGMobileLoginSDK

+ (instancetype)sharedInstance{
    static DGGMobileLoginSDK *_mobileLoginInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _mobileLoginInstance = [[DGGMobileLoginSDK alloc] init];
    });
    return _mobileLoginInstance;
}

- (instancetype)init{
    @synchronized (self) {
        self = [super init];
        if(self){
            
        }
        return self;
    }
}

- (NSInteger)carrier{
    return [[NTESQuickLoginManager sharedInstance] getCarrier];
}

#pragma mark - 网易易盾SDK注册操作/查询是否支持一键登录
- (void)precheckMobileLoginWithBlock:(void (^)(NSString *))resultBlock {
    self.shouldQL = [[NTESQuickLoginManager sharedInstance] shouldQuickLogin];
    if (self.shouldQL) {
        //注册网易易盾业务ID
        [[NTESQuickLoginManager sharedInstance] registerWithBusinessID:self.loginBusinessId timeout:3*1000 configURL:nil extData:nil completion:^(NSDictionary * _Nullable params, BOOL success) {
            if (success) {
                NSString *token = [params objectForKey:@"token"];
                self.quickPassToken = token;
                self.precheckSuccess = YES;
                if(resultBlock){
                    resultBlock(token);
                }
            } else {
                NSLog(@"precheck失败");
                self.precheckSuccess = NO;
            }
        }];
    }else{
        NSLog(@"不允许一键登录");
    }
}


@end
